package com.iccaplayer;

import com.example.iccaplayer.R;
import com.example.iccaplayer.R.layout;
import com.example.iccaplayer.R.menu;

import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;

public class SettingMidiNameActivity extends Activity {

	Intent mainIntent;

	EditText midiNameEdit;
	Button okBtn, cancelBtn;	

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_setting_midi_name);
		
		mainIntent = getIntent();

		midiNameEdit = (EditText)findViewById(R.id.MidiNameEditText);

		okBtn = (Button)findViewById(R.id.MidiOkBtn);
		// Close Information of Instrument Activity
		okBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				String midiName;
				midiName = midiNameEdit.getText() + "";
				mainIntent.putExtra("MidiName", midiName);
				setResult(RESULT_OK, mainIntent);
				finish();
			}
		});		

		// Close Information of Instrument Activity
		cancelBtn = (Button)findViewById(R.id.MidiCancelBtn);
		cancelBtn.setOnClickListener(new OnClickListener() {

			@Override
			public void onClick(View v) {
				setResult(RESULT_CANCELED);
				finish();
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		// Inflate the menu; this adds items to the action bar if it is present.
		getMenuInflater().inflate(R.menu.setting_midi_name, menu);
		return true;
	}

}
